package com.jiyang.jyandroid.test01;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.LinearLayout;
import android.widget.SeekBar;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/10/10.
 * 实验1-02 跟随手指移动的小球
 */

public class One_2Activity extends BaseActivity {
    private DrawView drawView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test01_2);
        //获取布局容器
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.root);
        //实例化小球
        drawView = new DrawView(this);

        linearLayout.addView(drawView);
        //获取拖动条
        SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
        //设置拖动监听
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                //当拖动条拖动，改变小球半径
                drawView.setRadio(progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }
}
